package com.ls.lsojcodesandbox.service;

import com.ls.lsojcodesandbox.JavaDockerSandbox;
import com.ls.lsojcodesandbox.config.RabbitMQConfig;
import com.ls.lsojcodesandbox.model.ExecuteCodeRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class QuestionSubmitMessageQueueListenerService {

    @Resource
    private CodeExecutionService codeExecutionService; // 注入新的异步服务

    @RabbitListener(queues = RabbitMQConfig.QUESTION_SUBMIT_QUEUE)
    public void acceptMessage(String submitId) {
        log.info("接收到消息：{}", submitId);
        codeExecutionService.execute(Long.valueOf(submitId));
    }
}
